package org.jeecg.modules.common.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.common.util.LoginUserUtil;
import org.jeecg.modules.qyxx.entity.CsPtQyxx;
import org.jeecg.modules.system.entity.SysDepart;
import org.jeecg.modules.system.service.ISysDepartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags="公共基础信息")
@RestController
@RequestMapping("/tax/common")
public class TaxCommonController {

    @Autowired
    private ISysDepartService sysDepartService;

    @ApiOperation(value="获取当前登录用户所属部门", notes="获取当前登录用户所属部门")
    @RequestMapping("curCompany")
    public Result<SysDepart> curDepart(){
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        SysDepart depart = sysDepartService.getDepartById(sysUser.getCompanyId());
        return Result.ok(depart);
    }

    @ApiOperation(value="企业信息-获取当前登录用户管辖的企业信息列表", notes="企业信息-获取当前登录用户管辖的企业信息列表")
    @GetMapping(value = "/getQyxxListByLoginUser")
    public Result<List<CsPtQyxx>> getQyxxListByLoginUser() {
        List<CsPtQyxx> list = LoginUserUtil.getQyxxListByLoginUser();
        return Result.OK(list);
    }

}
